import request from './request'

/**
 * 实验模板 API
 */

// 获取实验模板列表
export const getTemplateList = (params) => {
  return request({
    url: '/experiment-templates',
    method: 'get',
    params
  })
}

// 获取实验模板详情
export const getTemplateDetail = (id) => {
  return request({
    url: `/experiment-templates/${id}`,
    method: 'get'
  })
}

// 创建实验模板
export const createTemplate = (data) => {
  return request({
    url: '/experiment-templates',
    method: 'post',
    data
  })
}

// 更新实验模板
export const updateTemplate = (id, data) => {
  return request({
    url: `/experiment-templates/${id}`,
    method: 'put',
    data
  })
}

// 删除实验模板
export const deleteTemplate = (id) => {
  return request({
    url: `/experiment-templates/${id}`,
    method: 'delete'
  })
}

// 获取版本对比
export const getVersionDiff = (id, params) => {
  return request({
    url: `/experiment-templates/${id}/versions/diff`,
    method: 'get',
    params
  })
}

// 版本回滚
export const rollbackVersion = (id, version) => {
  return request({
    url: `/experiment-templates/${id}/versions/${version}/rollback`,
    method: 'post'
  })
}
